package interview.isbst;

import interview.common.BinaryTreeNode;

public class IsBinarySearchTree {
	public boolean isBST(BinaryTreeNode root) {
		if(root == null) {
			return true;
		}
		
		if(root.getLeft() != null && root.getData() < root.getLeft().getData()) {
			return false;
		}
		
		if(root.getRight() != null && root.getData() > root.getRight().getData()) {
			return false;
		}
		
		return isBST(root.getLeft()) && isBST(root.getRight());
	}
}
